<?php
	include "public/commom/config.php";//引入配置连接数据库文件
	
	if(isset($_SESSION["user_id"])) {
		if($_POST){
			$content = $_POST["content"];//微博内容
			$privacy = $_POST["privacy"];//微博隐私
			$time = time();//获取当前时间戳
			$user_id = $_SESSION["user_id"];//用户id
			
			$sql = "INSERT INTO weibo (content, privacy, time, user_id) VALUES ('$content', '$privacy', '$time', '$user_id')";//sql语句  - 发布微博
			
			$result = mysqli_query($conn, $sql);//result - 执行sql语句
			
			mysqli_close($conn);//关闭数据库连接
				
			header("Location: ./index.php");//跳转页面
		}
	}else {
		echo "您还未登录，请登录。";
	}
?>